package com.graduationdesign.zengyan.graduationdesignapp.ui.base;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.graduationdesign.zengyan.graduationdesignapp.ui.base.errorhandle.BaseErrorView;
import com.graduationdesign.zengyan.graduationdesignapp.ui.base.errorhandle.CommonErrorView;

import butterknife.ButterKnife;

/**
 * Created by ZengYan on 2018/4/24.
 *
 * @desc :
 */
public abstract class BaseActivity extends AppCompatActivity {

    public BaseErrorView mErrorView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (isFullScreen()) tranStatusBar();
        setContentView(provideLayoutId());
        ButterKnife.bind(this);
        initBaseView();
        initArgument();
        initPresenter();
        initToolbar();
        initView();
        start();
    }

    protected void initBaseView() {
        mErrorView = new CommonErrorView(this);
    }


    protected abstract @LayoutRes int provideLayoutId();

    protected abstract Boolean isFullScreen();

    protected abstract void initArgument();

    protected abstract void initPresenter();

    protected abstract void initToolbar();

    protected abstract void initView();

    protected abstract void start();

    /**
     * 状态栏透明化
     */
    private void tranStatusBar() {
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
    }


}
